import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class simulate {
    public String countAndSay(int n) {
        String ret = "1";
        for (int i = 2; i <= n; i++) {
            int len = ret.length();
            char[] arr = ret.toCharArray();
            int left = 0, right = 0;
            ret = "";
            while (right < len) {
                while (right < len && arr[right] == arr[left]) {
                    right++;
                }
                int count = right - left;
                ret += (count + "");
                ret += arr[left];
                left = right;
            }
        }
        return ret;
    }

//    public static void main(String[] args) {
//        simulate.countAndSay(4);
//    }
}
